#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

void solve()
{
    int n; cin >> n;
    vector<int> arr;
    long long num = 0;
    for (int i = 0; i < n; i++)
    {
        int temp; cin >> temp;
        num += temp;
        arr.push_back(temp);
    }
    sort(arr.begin(), arr.end());
    if (n <= 2)
    {
        cout << -1 << endl; return;
    }
    long long head = 0, tail = (long long)2 * n * arr.back();
    while (head < tail)
    {
        long long mid = (head + tail) / 2;
        double temp = (num + mid) * 1.0 / n;
        int cnt = 0;
        for (int j = 0; j < arr.size() - 1; j++)
        {
            if (arr[j] < temp / 2) cnt += 1;
            else break;
        }
        if (cnt * 2 > n) tail = mid;
        else head = mid + 1;
    }
    cout << head << endl;
}

int main()
{
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}